package com.amigo.online.provider.user.mapper;

import com.amigo.online.common.param.result.activity.User;
import com.amigo.online.provider.user.model.entity.collection.ActivityTblPo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface ActivityMapper  {
    @Update("UPDATE activity_tbl SET deleted = 1, delete_time = NOW() WHERE id = #{id} AND user_id = #{userId}")
    int deleteById(@Param("id") long id, @Param("userId") long userId);

    @Update("UPDATE activity_tbl SET join_member_num = join_member_num + #{num} WHERE id = #{id}")
    int updeteJoinMemberNum(@Param("id") long id, @Param("num") int num);


    @Update("UPDATE activity_participate_tbl SET cancel = true,cancel_time = #{cancelTime}" +
            " WHERE  activity_id = #{activityId} and user_id = #{userId} and cancel = false ")
    int cancelParticipateActivity(@Param("cancelTime") Date cancelTime, @Param("activityId") long activityId, @Param("userId") long userId);

    /**
     * 根据用户查活动,如果没有用户,查所有
     * @param userId
     * @param start
     * @return
     */
    List<ActivityTblPo> selectByUser(@Param("start") int start,@Param("userIds") Long... userIds);

    List<ActivityTblPo> getActivitiesIParticipated(@Param("start") int start,@Param("userId") Long userId);


    List<User> selectActivityParticipate(long id);

}